Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend the irrefutable_let_patterns lint to let chains #94951

Merged
merged 1 commit into from
Mar 16, 2022

Conversation

est31
Copy link
Member

@est31 est31 commented Mar 15, 2022

Implements the suggestion from #94927 (comment)

We only look for complete suffixes or prefixes of irrefutable let patterns, so
that an irrefutable let pattern in a chain surrounded by refutable ones is
not linted, as it is an useful pattern that has no low-cost replacement (unlike suffixes or prefixes which can just be moved outside of the if: either into the if's block, or the block surrounding the if).
If all patterns in a let chain are irrefutable, we lint as well.

Depends on #94958 so I included it into the PR for now which has been merged since.

r? @estebank

cc @joshtriplett @c410-f3r

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 15, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 15, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@est31 est31 force-pushed the irrefutable_let_chain_patterns branch 2 times, most recently from 3ca8f0e to ce3cdd2 Compare March 15, 2022 17:16
@rust-log-analyzer

This comment has been minimized.

@est31 est31 force-pushed the irrefutable_let_chain_patterns branch 2 times, most recently from 284fb1a to fb38040 Compare March 15, 2022 21:43
@rust-log-analyzer

This comment has been minimized.

@est31 est31 force-pushed the irrefutable_let_chain_patterns branch from fb38040 to a574d3a Compare March 15, 2022 22:29
@rust-log-analyzer

This comment has been minimized.

@est31 est31 force-pushed the irrefutable_let_chain_patterns branch from a574d3a to cafb407 Compare March 15, 2022 22:46
@rust-log-analyzer

This comment has been minimized.

Only look for complete suffixes or prefixes of irrefutable let patterns, so
that an irrefutable let pattern in a chain surrounded by refutable ones is
not linted, as it is an useful pattern.
@est31 est31 force-pushed the irrefutable_let_chain_patterns branch from cafb407 to 0f4c81a Compare March 15, 2022 23:32
@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 16, 2022

📌 Commit 0f4c81a has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 16, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 16, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#94868 (Format core and std macro rules, removing needless surrounding blocks)
 - rust-lang#94951 (Extend the irrefutable_let_patterns lint to let chains)
 - rust-lang#94955 (Refactor: Use `format_args_capture` in some parts of `rustc_parse`)
 - rust-lang#94957 (Improve the explanation about the behaviour of read_line)
 - rust-lang#94974 (Ensure that `let_else` does not interact with `let_chains`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Mar 16, 2022

⌛ Testing commit 0f4c81a with merge a2af9cf...

@bors bors merged commit 2bd5c44 into rust-lang:master Mar 16, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 16, 2022
@c410-f3r
Copy link
Contributor

Thanks @est31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants